// 在组件内定义vue过滤器
<template>
  <div>{{m}}分{{s}}秒</div>
</template>
<script>
export default {
  props: ["time"],
  data() {
    return {
      newTime: 0,
      m: 0,
      s: 0
    };
  },

  created() {
    this.newTime = this.time / 1000;
    this.countDown();
  },

  methods: {
    // 倒计时
    countDown() {
      setInterval(() => {
        this.newTime--;
        // newTime包含了多少分钟
        this.m = Math.floor(this.newTime / 60);
        // 计算秒数
        this.s = Math.floor(this.newTime % 60);
      }, 1000);
    }
  }
};
</script>